package com.library.service.impl;


import com.library.common.core.text.Convert;
import com.library.domain.MbAdvertising;
import com.library.mapper.MbAdvertisingMapper;
import com.library.service.IMbAdvertisingService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 广告管理 服务层实现
 *
 * @author null
 * @date 2020-04-23
 * @blame Android Team
 */
@Service
public class MbAdvertisingServiceImpl implements IMbAdvertisingService {
    @Resource
    private MbAdvertisingMapper mbAdvertisingMapper;

    /**
     * 查询广告管理信息
     *
     * @param id 广告管理ID
     * @return 广告管理信息
     */
    @Override
    public MbAdvertising selectMbAdvertisingById(Long id) {
        return mbAdvertisingMapper.selectMbAdvertisingById(id);
    }

    /**
     * 查询广告管理列表
     *
     * @param mbAdvertising 广告管理信息
     * @return 广告管理集合
     */
    @Override
    public List<MbAdvertising> selectMbAdvertisingList(MbAdvertising mbAdvertising) {
        return mbAdvertisingMapper.selectMbAdvertisingList(mbAdvertising);
    }

    /**
     * 新增广告管理
     *
     * @param mbAdvertising 广告管理信息
     * @return 结果
     */
    @Override
    public int insertMbAdvertising(MbAdvertising mbAdvertising) {
        return mbAdvertisingMapper.insertMbAdvertising(mbAdvertising);
    }

    /**
     * 修改广告管理
     *
     * @param mbAdvertising 广告管理信息
     * @return 结果
     */
    @Override
    public int updateMbAdvertising(MbAdvertising mbAdvertising) {
        return mbAdvertisingMapper.updateMbAdvertising(mbAdvertising);
    }

    /**
     * 删除广告管理对象
     *
     * @param ids 需要删除的数据ID
     * @return 结果
     */
    @Override
    public int deleteMbAdvertisingByIds(Long[] ids) {
        for (Long id : ids) {
            MbAdvertising mbAdvertising = mbAdvertisingMapper.selectMbAdvertisingById(id);
            mbAdvertising.setIsDelete(MbAdvertising.DELETE);
            mbAdvertisingMapper.updateMbAdvertising(mbAdvertising);
        }
        return MbAdvertising.DELETE;
    }

}
